package com.fr.report.core;

import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.FRFont;
import com.fr.base.Painter;
import com.fr.base.StringUtils;
import com.fr.base.Style;
import com.fr.base.background.Background;
import com.fr.base.background.ColorBackground;
import com.fr.base.core.BaseCoreConstants;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.DateUtils;
import com.fr.base.core.FRCoreContext;
import com.fr.base.core.GraphHelper;
import com.fr.data.condition.ListCondition;
import com.fr.report.CellElement;
import com.fr.report.FloatElement;
import com.fr.report.cellElement.BarcodeAttr;
import com.fr.report.cellElement.CellExpandAttr;
import com.fr.report.cellElement.CellPageAttr;
import com.fr.report.cellElement.Formula;
import com.fr.report.cellElement.core.DSColumn;
import com.fr.report.cellElement.core.ResultSubReport;
import com.fr.report.core.barcode.BarCodeUtils;
import com.fr.report.core.barcode.BarcodeException;
import com.fr.report.core.barcode.BarcodeImpl;
import com.fr.report.highlight.HighlightGroup;
import com.fr.report.web.ui.Widget;
import com.fr.util.Utils;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.awt.font.TransformAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D.Double;
import java.awt.image.BufferedImage;
import java.sql.Clob;
import java.text.DateFormat;
import java.text.Format;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;

public class PaintUtils
{
  public static final int Cell_Mark_Size = 6;
  public static final Color Cell_HightLight_Mark_Color = Color.RED;
  public static final Color Cell_Present_Mark_Color = Color.CYAN;
  public static final Color Cell_Pagination_Mark_Color = Color.GREEN;
  public static final Color Cell_Write_Mark_Color = Color.BLUE;
  public static final Color Cell_ConditionFilter_Mark_Color = Color.ORANGE;
  public static final Color Cell_Direction_Mark_Color = Color.gray;
  private static Hashtable fontAttributeMapCache = new Hashtable();
  private static Rectangle2D tempRectangle2D = new Rectangle2D.Double(0.0D, 0.0D, 0.0D, 0.0D);

  public static void paintGridCellContent(Graphics2D paramGraphics2D, CellElement paramCellElement, int paramInt1, int paramInt2)
  {
    int i = 6;
    int j = 0;
    if ((paramCellElement.getHighlightGroup() != null) && (paramCellElement.getHighlightGroup().size() > 0))
    {
      localObject1 = paramGraphics2D.getPaint();
      paramGraphics2D.setPaint(Cell_HightLight_Mark_Color);
      localObject2 = new GeneralPath(0, 3);
      ((GeneralPath)localObject2).moveTo(0.0F, 0.0F);
      ((GeneralPath)localObject2).lineTo(0.0F, i);
      ((GeneralPath)localObject2).lineTo(i, 0.0F);
      GraphHelper.fill(paramGraphics2D, (Shape)localObject2);
      paramGraphics2D.setPaint((Paint)localObject1);
      ++j;
    }
    if (paramCellElement.getPresent() != null)
    {
      localObject1 = paramGraphics2D.getPaint();
      paramGraphics2D.setPaint(Cell_Present_Mark_Color);
      localObject2 = new GeneralPath(0, 3);
      ((GeneralPath)localObject2).moveTo(0 + j * i, 0.0F);
      ((GeneralPath)localObject2).lineTo(0 + j * i, 6.0F);
      ((GeneralPath)localObject2).lineTo(i + j * i, 0.0F);
      GraphHelper.fill(paramGraphics2D, (Shape)localObject2);
      paramGraphics2D.setPaint((Paint)localObject1);
      ++j;
    }
    if ((paramCellElement.getCellPageAttr() != null) && (((paramCellElement.getCellPageAttr().isPageAfterColumn()) || (paramCellElement.getCellPageAttr().isPageBeforeColumn()) || (paramCellElement.getCellPageAttr().isPageAfterRow()) || (paramCellElement.getCellPageAttr().isPageBeforeRow()))))
    {
      localObject1 = paramGraphics2D.getPaint();
      paramGraphics2D.setPaint(Cell_Pagination_Mark_Color);
      localObject2 = new GeneralPath(0, 3);
      ((GeneralPath)localObject2).moveTo(paramInt1, 0.0F);
      ((GeneralPath)localObject2).lineTo(paramInt1, i);
      ((GeneralPath)localObject2).lineTo(paramInt1 - i, 0.0F);
      GraphHelper.fill(paramGraphics2D, (Shape)localObject2);
      paramGraphics2D.setPaint((Paint)localObject1);
    }
    if (paramCellElement.getWidget() != null)
    {
      localObject1 = paramCellElement.getWidget();
      localObject2 = ((ImageIcon)ReportUtils.createWidgetIcon((Widget)localObject1)).getImage();
      paramGraphics2D.setComposite(AlphaComposite.getInstance(10, 0.67F));
      paramGraphics2D.drawImage((Image)localObject2, paramInt1 - 15, paramInt2 - 15, 15, 15, null);
      paramGraphics2D.setComposite(AlphaComposite.getInstance(3));
    }
    Object localObject1 = paramCellElement.getCellExpandAttr();
    if (localObject1 != null)
      if (((CellExpandAttr)localObject1).getDirection() == 0)
      {
        localObject2 = paramGraphics2D.getPaint();
        paramGraphics2D.setPaint(Cell_Direction_Mark_Color);
        GraphHelper.drawLine(paramGraphics2D, 2.0D, 0.0D, 2.0D, 5.0D);
        GraphHelper.drawLine(paramGraphics2D, 2.0D, 5.0D, 0.0D, 2.0D);
        GraphHelper.drawLine(paramGraphics2D, 2.0D, 5.0D, 4.0D, 2.0D);
        paramGraphics2D.setPaint((Paint)localObject2);
      }
      else if (((CellExpandAttr)localObject1).getDirection() == 1)
      {
        localObject2 = paramGraphics2D.getPaint();
        paramGraphics2D.setPaint(Cell_Direction_Mark_Color);
        GraphHelper.drawLine(paramGraphics2D, 0.0D, 2.0D, 5.0D, 2.0D);
        GraphHelper.drawLine(paramGraphics2D, 5.0D, 2.0D, 2.0D, 0.0D);
        GraphHelper.drawLine(paramGraphics2D, 5.0D, 2.0D, 2.0D, 4.0D);
        paramGraphics2D.setPaint((Paint)localObject2);
      }
    Object localObject2 = paramCellElement.getValue();
    if (localObject2 == null)
      return;
    if ((localObject2 instanceof DSColumn) && (((DSColumn)localObject2).getCondition() != null))
    {
      if ((((DSColumn)localObject2).getCondition() instanceof ListCondition) && (((ListCondition)((DSColumn)localObject2).getCondition()).getJoinConditionCount() == 0))
        break label670:
      Paint localPaint = paramGraphics2D.getPaint();
      paramGraphics2D.setPaint(Cell_ConditionFilter_Mark_Color);
      GeneralPath localGeneralPath = new GeneralPath(0, 3);
      localGeneralPath.moveTo(0.0F, paramInt2);
      localGeneralPath.lineTo(i + 1, paramInt2);
      localGeneralPath.lineTo(0.0F, paramInt2 - 1 - i);
      GraphHelper.fill(paramGraphics2D, localGeneralPath);
      paramGraphics2D.setPaint(localPaint);
    }
    if (localObject2 instanceof Formula)
      label670: localObject2 = ((Formula)localObject2).getContent();
    if (localObject2 instanceof ResultSubReport)
    {
      localObject2 = BaseUtils.readImage("/com/fr/design/images/m_insert/subReport.png");
      GraphHelper.paintImage(paramGraphics2D, paramInt1, paramInt2, (Image)localObject2, paramCellElement.getStyle(), 1, (paramInt1 > 16) ? 16 : paramInt1, (paramInt2 > 16) ? 16 : paramInt2);
    }
    else
    {
      paintContent(paramGraphics2D, localObject2, paramCellElement.getStyle(), paramInt1, paramInt2);
    }
  }

  public static void paintFloatElement(Graphics2D paramGraphics2D, FloatElement paramFloatElement, int paramInt1, int paramInt2)
  {
    paintBackground(paramGraphics2D, paramFloatElement.getStyle(), paramInt1, paramInt2);
    Object localObject = paramFloatElement.getValue();
    if (localObject instanceof Formula)
      localObject = ((Formula)localObject).getContent();
    paintContent(paramGraphics2D, localObject, paramFloatElement.getStyle(), paramInt1, paramInt2);
    paintBorder(paramGraphics2D, paramFloatElement.getStyle(), paramInt1, paramInt2);
  }

  public static void paintFloatElement(Graphics2D paramGraphics2D, FloatElement paramFloatElement, Rectangle paramRectangle1, Rectangle paramRectangle2)
  {
    paintBackground(paramGraphics2D, paramFloatElement.getStyle(), paramRectangle1, paramRectangle2);
    paintContent(paramGraphics2D, paramFloatElement.getValue(), paramFloatElement.getStyle(), paramRectangle1, paramRectangle2);
    paintBorder(paramGraphics2D, paramFloatElement.getStyle(), paramRectangle1, paramRectangle2);
  }

  public static void paintContent(Graphics2D paramGraphics2D, Object paramObject, Style paramStyle, int paramInt1, int paramInt2)
  {
    if ((paramObject == null) || (paramInt1 == 0) || (paramInt2 == 0))
      return;
    if (paramStyle == null)
      paramStyle = Style.DEFAULT_STYLE;
    if (paramObject instanceof Formula)
      paramObject = ((Formula)paramObject).getResult();
    if (paramObject instanceof Painter)
    {
      ((Painter)paramObject).paint(paramGraphics2D, paramInt1, paramInt2, paramStyle);
    }
    else if (paramObject instanceof Image)
    {
      GraphHelper.paintImage(paramGraphics2D, paramInt1, paramInt2, (Image)paramObject, paramStyle, paramStyle.getImageLayout(), -1, -1);
    }
    else
    {
      String str = valueToText(paramObject, paramStyle.getFormat());
      paintCellStyleString(paramGraphics2D, paramInt1, paramInt2, str, paramStyle);
    }
  }

  public static void paintContent(Graphics2D paramGraphics2D, Object paramObject, Style paramStyle, Rectangle paramRectangle1, Rectangle paramRectangle2)
  {
    Shape localShape = paramGraphics2D.getClip();
    paramGraphics2D.translate(paramRectangle1.getX(), paramRectangle1.getY());
    paramGraphics2D.clip(paramRectangle2);
    paintContent(paramGraphics2D, paramObject, paramStyle, paramRectangle1.width, paramRectangle1.height);
    paramGraphics2D.translate(-paramRectangle1.getX(), -paramRectangle1.getY());
    paramGraphics2D.setClip(localShape);
  }

  public static void paintHTMLContent(Graphics2D paramGraphics2D, String paramString, Style paramStyle, Rectangle paramRectangle1, Rectangle paramRectangle2)
  {
    BufferedImage localBufferedImage = createHTMLContentBufferedImage(paramString, paramRectangle1);
    paintContent(paramGraphics2D, localBufferedImage, paramStyle, paramRectangle1, paramRectangle2);
  }

  public static BufferedImage createHTMLContentBufferedImage(String paramString, Rectangle paramRectangle)
  {
    BufferedImage localBufferedImage = GraphHelper.createBufferedImage(paramRectangle.width, paramRectangle.height, 6);
    Graphics2D localGraphics2D = localBufferedImage.createGraphics();
    localGraphics2D.setPaint(Color.white);
    JEditorPane localJEditorPane = new JEditorPane();
    localJEditorPane.setContentType("text/html");
    localJEditorPane.setSize((int)paramRectangle.getWidth() - 1, (int)paramRectangle.getHeight() - 1);
    localJEditorPane.setText(paramString);
    localJEditorPane.paint(localGraphics2D);
    int i = localJEditorPane.getComponentCount();
    for (int j = 0; j < i; ++j)
    {
      Component localComponent1 = localJEditorPane.getComponent(j);
      if (localComponent1 instanceof Container)
      {
        Container localContainer = (Container)localComponent1;
        localComponent1.doLayout();
        int k = localContainer.getComponentCount();
        if (k > 0)
        {
          Component localComponent2 = localContainer.getComponent(0);
          localGraphics2D.translate(localContainer.getX(), localContainer.getY());
          localComponent2.paint(localGraphics2D);
          localGraphics2D.translate(-localContainer.getX(), -localContainer.getY());
        }
      }
    }
    localBufferedImage.flush();
    localGraphics2D.dispose();
    return localBufferedImage;
  }

  public static void paintBackground(Graphics2D paramGraphics2D, Style paramStyle, double paramDouble1, double paramDouble2)
  {
    if (paramStyle == null)
      return;
    Background localBackground = paramStyle.getBackground();
    if (localBackground != null)
    {
      tempRectangle2D.setRect(0.0D, 0.0D, paramDouble1, paramDouble2);
      localBackground.paint(paramGraphics2D, tempRectangle2D);
    }
  }

  public static void paintBackground(Graphics2D paramGraphics2D, Style paramStyle, Rectangle paramRectangle1, Rectangle paramRectangle2)
  {
    if (paramStyle == null)
      paramStyle = Style.DEFAULT_STYLE;
    Background localBackground = paramStyle.getBackground();
    if (localBackground != null)
      localBackground.paint(paramGraphics2D, new Rectangle(paramRectangle1.x + paramRectangle2.x, paramRectangle1.y + paramRectangle2.y, paramRectangle2.width, paramRectangle2.height));
  }

  public static void paintBorder(Graphics2D paramGraphics2D, Style paramStyle, double paramDouble1, double paramDouble2)
  {
    int i1;
    if (paramStyle == null)
      return;
    int i = 0;
    int j = 0;
    if (paramStyle.getBorderLeft() != 0)
    {
      k = GraphHelper.getLineStyleSize(paramStyle.getBorderLeft());
      i = k / 2;
    }
    if (paramStyle.getBorderRight() != 0)
    {
      k = GraphHelper.getLineStyleSize(paramStyle.getBorderRight());
      j = k / 2;
    }
    int k = 0;
    int l = 0;
    if (paramStyle.getBorderTop() != 0)
    {
      i1 = GraphHelper.getLineStyleSize(paramStyle.getBorderTop());
      k = i1 / 2;
    }
    if (paramStyle.getBorderBottom() != 0)
    {
      i1 = GraphHelper.getLineStyleSize(paramStyle.getBorderBottom());
      l = i1 / 2;
    }
    if (paramStyle.getBorderTop() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderTopColor());
      GraphHelper.drawLine(paramGraphics2D, 0 - i, 0.0D, paramDouble1 + j, 0.0D, paramStyle.getBorderTop());
    }
    if (paramStyle.getBorderLeft() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderLeftColor());
      GraphHelper.drawLine(paramGraphics2D, 0.0D, 0 - k, 0.0D, paramDouble2 + l, paramStyle.getBorderLeft());
    }
    if (paramStyle.getBorderBottom() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderBottomColor());
      GraphHelper.drawLine(paramGraphics2D, 0 - i, paramDouble2, paramDouble1 + j, paramDouble2, paramStyle.getBorderBottom());
    }
    if (paramStyle.getBorderRight() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderRightColor());
      GraphHelper.drawLine(paramGraphics2D, paramDouble1, 0 - k, paramDouble1, paramDouble2 + l, paramStyle.getBorderRight());
    }
  }

  public static void paintBorder(Graphics2D paramGraphics2D, Style paramStyle, Rectangle paramRectangle1, Rectangle paramRectangle2)
  {
    int i1;
    paramGraphics2D.translate(paramRectangle1.getX(), paramRectangle1.getY());
    Rectangle localRectangle = new Rectangle(0, 0, paramRectangle1.width, paramRectangle1.height);
    if (paramRectangle2 != null)
      localRectangle = localRectangle.intersection(paramRectangle2);
    paramGraphics2D.translate(localRectangle.getX(), localRectangle.getY());
    if (paramStyle == null)
      paramStyle = Style.DEFAULT_STYLE;
    int i = 0;
    int j = 0;
    if (paramStyle.getBorderLeft() != 0)
    {
      k = GraphHelper.getLineStyleSize(paramStyle.getBorderLeft());
      i = k / 2;
    }
    if (paramStyle.getBorderRight() != 0)
    {
      k = GraphHelper.getLineStyleSize(paramStyle.getBorderRight());
      j = k / 2;
    }
    int k = 0;
    int l = 0;
    if (paramStyle.getBorderTop() != 0)
    {
      i1 = GraphHelper.getLineStyleSize(paramStyle.getBorderTop());
      k = i1 / 2;
    }
    if (paramStyle.getBorderBottom() != 0)
    {
      i1 = GraphHelper.getLineStyleSize(paramStyle.getBorderBottom());
      l = i1 / 2;
    }
    if (paramStyle.getBorderTop() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderTopColor());
      GraphHelper.drawLine(paramGraphics2D, 0 - i, 0.0D, localRectangle.getWidth() + j, 0.0D, paramStyle.getBorderTop());
    }
    if (paramStyle.getBorderLeft() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderLeftColor());
      GraphHelper.drawLine(paramGraphics2D, 0.0D, 0 - k, 0.0D, localRectangle.getHeight() + l, paramStyle.getBorderLeft());
    }
    if (paramStyle.getBorderBottom() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderBottomColor());
      GraphHelper.drawLine(paramGraphics2D, 0 - i, localRectangle.getHeight(), localRectangle.getWidth() + j, localRectangle.getHeight(), paramStyle.getBorderBottom());
    }
    if (paramStyle.getBorderRight() != 0)
    {
      paramGraphics2D.setPaint(paramStyle.getBorderRightColor());
      GraphHelper.drawLine(paramGraphics2D, localRectangle.getWidth(), 0 - k, localRectangle.getWidth(), localRectangle.getHeight() + l, paramStyle.getBorderRight());
    }
    paramGraphics2D.translate(-localRectangle.getX(), -localRectangle.getY());
    paramGraphics2D.translate(-paramRectangle1.getX(), -paramRectangle1.getY());
  }

  public static String valueToText(Object paramObject, Format paramFormat)
  {
    Object localObject1 = paramObject;
    String str = null;
    if (paramObject != null)
    {
      Object localObject2;
      if (paramObject instanceof Formula)
      {
        localObject2 = (Formula)paramObject;
        if (ReportHelper.isNull(((Formula)localObject2).getResult()))
          return ((Formula)localObject2).getContent();
        localObject1 = ((Formula)localObject2).getResult();
      }
      else if (paramObject instanceof Clob)
      {
        localObject1 = Utils.clob2String((Clob)paramObject);
      }
      if (paramFormat != null)
        if (paramFormat instanceof DateFormat)
        {
          localObject2 = DateUtils.object2Date(localObject1, true);
          if (localObject2 != null)
            str = paramFormat.format(localObject2);
          else
            str = Utils.objectToString(localObject1);
        }
        else if (paramFormat instanceof NumberFormat)
        {
          if (localObject1 instanceof Number)
          {
            try
            {
              str = ((NumberFormat)paramFormat).format(localObject1);
            }
            catch (Exception localException1)
            {
              str = Utils.objectToString(localObject1);
            }
          }
          else
          {
            str = Utils.objectToString(localObject1);
            try
            {
              str = ((NumberFormat)paramFormat).format(Double.parseDouble(str));
            }
            catch (Exception localException2)
            {
            }
          }
        }
        else
        {
          try
          {
            str = paramFormat.format(localObject1);
          }
          catch (Exception localException3)
          {
            str = Utils.objectToString(localObject1);
          }
        }
      else
        str = Utils.objectToString(localObject1);
    }
    else
    {
      str = "";
    }
    return ((String)(String)str);
  }

  public static boolean isLetter(char paramChar)
  {
    return (((paramChar >= 'A') && (paramChar <= 'Z')) || ((paramChar >= 'a') && (paramChar <= 'z')));
  }

  public static int getLineTextCount(String paramString, Style paramStyle, double paramDouble)
  {
    if (paramStyle.getRotation() != 0)
      return 1;
    int i = 0;
    FRFont localFRFont = paramStyle.getFRFont();
    FontMetrics localFontMetrics = GraphHelper.getFontMetrics(localFRFont);
    char[] arrayOfChar = paramString.toCharArray();
    if (paramStyle.getTextStyle() != 0)
    {
      int j = 0;
      for (int k = 0; k < arrayOfChar.length; ++k)
        if (arrayOfChar[k] == '\\')
        {
          if ((k + 1 < arrayOfChar.length) && (arrayOfChar[(k + 1)] == 'n'))
          {
            ++k;
            ++i;
            if (j != 0)
              j = 0;
          }
          else if (j == 0)
          {
            j = 1;
          }
        }
        else if (arrayOfChar[k] == '\n')
        {
          ++i;
          if (j != 0)
            j = 0;
        }
        else if (j == 0)
        {
          j = 1;
        }
      if (j != 0)
        ++i;
      return i;
    }
    double d = paramDouble - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight();
    int l = 0;
    int i1 = 0;
    int i2 = 0;
    for (int i3 = 0; i3 < arrayOfChar.length; ++i3)
      if ((i3 != 0) && (isLetter(arrayOfChar[i3])) && (isLetter(arrayOfChar[(i3 - 1)])))
      {
        if (i2 + localFontMetrics.charWidth(arrayOfChar[i3]) > d)
        {
          if (i1 > 0)
          {
            ++i;
            if (l != 0)
              l = 0;
            i1 = 0;
          }
          ++i;
          i2 = 0;
        }
        i2 += localFontMetrics.charWidth(arrayOfChar[i3]);
      }
      else if (arrayOfChar[i3] == '\n')
      {
        if ((i1 + i2 > d) && (l != 0))
        {
          ++i;
          ++i;
        }
        else
        {
          ++i;
        }
        if (l != 0)
          l = 0;
        i1 = 0;
        i2 = 0;
      }
      else if ((arrayOfChar[i3] == '\\') && (i3 + 1 < arrayOfChar.length) && (arrayOfChar[(i3 + 1)] == 'n'))
      {
        ++i3;
        if ((i1 + i2 > d) && (l != 0))
          i += 2;
        else
          ++i;
        if (l != 0)
          l = 0;
        i1 = 0;
        i2 = 0;
      }
      else
      {
        if ((arrayOfChar[i3] == '\\') && (i3 + 1 < arrayOfChar.length) && (arrayOfChar[(i3 + 1)] == '\\'))
          ++i3;
        if ((i1 + i2 > d) && (l != 0))
        {
          ++i;
          i1 = 0;
        }
        if (l == 0)
          l = 1;
        i1 += i2;
        i2 = 0;
        i2 = localFontMetrics.charWidth(arrayOfChar[i3]);
      }
    if ((i1 + i2 > d) && (l != 0))
      i += 2;
    else
      ++i;
    return i;
  }

  public static List getLineTextList(String paramString, Style paramStyle, double paramDouble)
  {
    ArrayList localArrayList = new ArrayList();
    if ((paramString == null) || (paramString.length() <= 0))
      return localArrayList;
    paramStyle = (paramStyle == null) ? Style.DEFAULT_STYLE : paramStyle;
    if (paramStyle.getRotation() != 0)
    {
      localArrayList.add(paramString);
      return localArrayList;
    }
    FRFont localFRFont = paramStyle.getFRFont();
    FontMetrics localFontMetrics = GraphHelper.getFontMetrics(localFRFont);
    if (paramStyle.getTextStyle() != 0)
    {
      StringBuffer localStringBuffer1 = new StringBuffer();
      for (int i = 0; i < paramString.length(); ++i)
      {
        char c = paramString.charAt(i);
        if (c == '\\')
        {
          if ((i + 1 < paramString.length()) && (paramString.charAt(i + 1) == 'n'))
          {
            ++i;
            localArrayList.add(localStringBuffer1.toString());
            localStringBuffer1.delete(0, localStringBuffer1.length());
          }
          else
          {
            localStringBuffer1.append(c);
          }
        }
        else if (c == '\n')
        {
          localArrayList.add(localStringBuffer1.toString());
          localStringBuffer1.delete(0, localStringBuffer1.length());
        }
        else
        {
          localStringBuffer1.append(c);
        }
      }
      if (localStringBuffer1.length() > 0)
      {
        localArrayList.add(localStringBuffer1.toString());
        localStringBuffer1.delete(0, localStringBuffer1.length());
      }
      return localArrayList;
    }
    double d = paramDouble - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight();
    StringBuffer localStringBuffer2 = new StringBuffer();
    int j = 0;
    StringBuffer localStringBuffer3 = new StringBuffer();
    int k = 0;
    for (int l = 0; l < paramString.length(); ++l)
      if ((l != 0) && (isLetter(paramString.charAt(l))) && (isLetter(paramString.charAt(l - 1))))
      {
        if (k + localFontMetrics.charWidth(paramString.charAt(l)) > d)
        {
          if (j > 0)
          {
            localArrayList.add(localStringBuffer2.toString());
            localStringBuffer2.delete(0, localStringBuffer2.length());
            j = 0;
          }
          localArrayList.add(localStringBuffer3.toString());
          localStringBuffer3.delete(0, localStringBuffer3.length());
          k = 0;
        }
        localStringBuffer3.append(paramString.charAt(l));
        k += localFontMetrics.charWidth(paramString.charAt(l));
      }
      else if (paramString.charAt(l) == '\n')
      {
        if ((j + k > d) && (localStringBuffer2.length() > 0))
        {
          localArrayList.add(localStringBuffer2.toString());
          localArrayList.add(localStringBuffer3.toString());
        }
        else
        {
          localStringBuffer2.append(localStringBuffer3);
          localArrayList.add(localStringBuffer2.toString());
        }
        localStringBuffer2.delete(0, localStringBuffer2.length());
        j = 0;
        localStringBuffer3.delete(0, localStringBuffer3.length());
        k = 0;
      }
      else if ((paramString.charAt(l) == '\\') && (l + 1 < paramString.length()) && (paramString.charAt(l + 1) == 'n'))
      {
        ++l;
        if ((j + k > d) && (localStringBuffer2.length() > 0))
        {
          localArrayList.add(localStringBuffer2.toString());
          localArrayList.add(localStringBuffer3.toString());
        }
        else
        {
          localStringBuffer2.append(localStringBuffer3);
          localArrayList.add(localStringBuffer2.toString());
        }
        localStringBuffer2.delete(0, localStringBuffer2.length());
        j = 0;
        localStringBuffer3.delete(0, localStringBuffer3.length());
        k = 0;
      }
      else
      {
        if ((paramString.charAt(l) == '\\') && (l + 1 < paramString.length()) && (paramString.charAt(l + 1) == '\\'))
          ++l;
        if ((j + k > d) && (localStringBuffer2.length() > 0))
        {
          localArrayList.add(localStringBuffer2.toString());
          localStringBuffer2.delete(0, localStringBuffer2.length());
          j = 0;
        }
        localStringBuffer2.append(localStringBuffer3);
        j += k;
        localStringBuffer3.delete(0, localStringBuffer3.length());
        k = 0;
        localStringBuffer3.append(paramString.charAt(l));
        k = localFontMetrics.charWidth(paramString.charAt(l));
      }
    if ((j + k > d) && (localStringBuffer2.length() > 0))
    {
      localArrayList.add(localStringBuffer2.toString());
      localArrayList.add(localStringBuffer3.toString());
    }
    else
    {
      localStringBuffer2.append(localStringBuffer3);
      localArrayList.add(localStringBuffer2.toString());
    }
    return localArrayList;
  }

  public static List getLineTextList_Vertical(String paramString, Style paramStyle, double paramDouble)
  {
    label421: char c;
    int i1;
    int i2;
    if (paramStyle.getVerticalText() != 1)
      return getLineTextList(paramString, paramStyle, paramDouble);
    ArrayList localArrayList1 = new ArrayList();
    if ((paramString == null) || (paramString.length() <= 0))
      return localArrayList1;
    if (paramStyle == null)
    {
      paramStyle = Style.DEFAULT_STYLE;
      return getLineTextList(paramString, paramStyle, paramDouble);
    }
    if (paramStyle.getRotation() != 0)
    {
      localArrayList1.add(paramString);
      return localArrayList1;
    }
    ArrayList localArrayList2 = new ArrayList();
    int i = 0;
    FRFont localFRFont = paramStyle.getFRFont();
    FontMetrics localFontMetrics = GraphHelper.getFontMetrics(localFRFont);
    int j = localFontMetrics.getHeight();
    int k = paramStyle.getTextStyle();
    if (k == 0)
    {
      double d = paramDouble;
      i1 = 1;
      int i4 = 0;
      int i5 = 0;
      StringBuffer localStringBuffer3 = new StringBuffer();
      for (int i6 = 0; i6 < paramString.length(); ++i6)
      {
        i2 = paramString.charAt(i6);
        if ((i2 == 32) && (i1 == 0))
          break label421:
        if (i2 == 10)
        {
          localArrayList2.add(localStringBuffer3.toString());
          localStringBuffer3.delete(0, localStringBuffer3.length());
          i5 = 0;
          i4 = 0;
        }
        else
        {
          if (i2 != 32)
            i1 = 0;
          if (i2 == 92)
          {
            if ((i6 + 1 < paramString.length()) && (paramString.charAt(i6 + 1) == 'n'))
            {
              ++i6;
              localArrayList2.add(localStringBuffer3.toString());
              localStringBuffer3.delete(0, localStringBuffer3.length());
              i5 = 0;
              i = Math.max(i, ++i4);
              i4 = 0;
              break label421:
            }
            localStringBuffer3.append(i2);
            i5 += j;
            i = Math.max(i, ++i4);
          }
          else
          {
            localStringBuffer3.append(i2);
            i5 += j;
            i = Math.max(i, ++i4);
          }
          if (i5 > d)
          {
            localArrayList2.add(localStringBuffer3.substring(0, localStringBuffer3.length() - 1));
            localStringBuffer3.delete(0, localStringBuffer3.length() - 1);
            i5 = j;
            i = Math.max(i, i4 - 1);
            i4 = 1;
          }
        }
      }
      localArrayList2.add(localStringBuffer3.toString());
    }
    else
    {
      StringBuffer localStringBuffer1 = new StringBuffer();
      for (i1 = 0; i1 < paramString.length(); ++i1)
        if (i1 < paramString.length())
        {
          c = paramString.charAt(i1);
          if (c != '\n')
            if (c == '\\')
            {
              if ((i1 + 1 < paramString.length()) && (paramString.charAt(i1 + 1) == 'n'))
              {
                ++i1;
              }
              else
              {
                localStringBuffer1.append(c);
                ++i;
              }
            }
            else
            {
              localStringBuffer1.append(c);
              ++i;
            }
        }
      localArrayList2.add(localStringBuffer1.toString());
      localStringBuffer1.delete(0, localStringBuffer1.length());
    }
    for (int l = 0; l < i; ++l)
    {
      StringBuffer localStringBuffer2 = new StringBuffer();
      if (paramStyle.getTextDirection() == 1)
      {
        i2 = 0;
        while (true)
        {
          if (i2 >= localArrayList2.size())
            break label823;
          if (((String)localArrayList2.get(i2)).length() > l)
          {
            c = ((String)localArrayList2.get(i2)).charAt(l);
            localStringBuffer2.append(c);
            if (localFontMetrics.charWidth(c) == 6)
              localStringBuffer2.append(' ');
          }
          else
          {
            localStringBuffer2.append(' ');
            localStringBuffer2.append(' ');
          }
          ++i2;
        }
      }
      for (int i3 = localArrayList2.size() - 1; i3 >= 0; --i3)
        if (((String)localArrayList2.get(i3)).length() > l)
        {
          c = ((String)localArrayList2.get(i3)).charAt(l);
          localStringBuffer2.append(c);
          if (localFontMetrics.charWidth(c) == 6)
            localStringBuffer2.append(' ');
        }
        else
        {
          localStringBuffer2.append(' ');
          localStringBuffer2.append(' ');
        }
      localArrayList1.add(localStringBuffer2.toString());
    }
    label823: return localArrayList1;
  }

  public static double getPreferredWidth(CellElement paramCellElement, int paramInt)
  {
    if (paramCellElement == null)
      return 0.0D;
    Object localObject = paramCellElement.getValue();
    if (localObject instanceof Formula)
      if (((Formula)localObject).getResult() != null)
        localObject = ((Formula)localObject).getResult();
      else
        localObject = "";
    Style localStyle = paramCellElement.getStyle();
    if (localStyle == null)
      localStyle = Style.DEFAULT_STYLE;
    String str = valueToText(localObject, localStyle.getFormat());
    FRFont localFRFont = localStyle.getFRFont();
    FontMetrics localFontMetrics = GraphHelper.getFontMetrics(localFRFont);
    return (localFontMetrics.stringWidth(str) + 4);
  }

  public static int analyzeCellElementPreferredHeight(CellElement paramCellElement, int paramInt)
  {
    Object localObject = paramCellElement.getValue();
    Style localStyle = paramCellElement.getStyle();
    if (localObject instanceof Formula)
      if (((Formula)localObject).getResult() != null)
        localObject = ((Formula)localObject).getResult();
      else
        localObject = "";
    String str = valueToText(localObject, localStyle.getFormat());
    return analyzeCellElementPreferredHeight(str, localStyle, paramInt);
  }

  public static int analyzeCellElementPreferredHeight(String paramString, Style paramStyle, int paramInt)
  {
    if (paramStyle == null)
      paramStyle = Style.DEFAULT_STYLE;
    if ((paramString == null) || (paramString.length() <= 0))
      return 0;
    if (paramStyle.getRotation() != 0)
      return (int)GraphHelper.stringDimension(paramString, paramStyle.getFRFont(), -paramStyle.getRotation(), BaseCoreConstants.DEFAULT_FRC).getHeight();
    int i = getLineTextCount(paramString, paramStyle, paramInt);
    FRFont localFRFont = paramStyle.getFRFont();
    FontMetrics localFontMetrics = GraphHelper.getFontMetrics(localFRFont);
    int j = localFontMetrics.getHeight();
    return (paramStyle.getSpacingAfter() + paramStyle.getSpacingBefore() + (j + paramStyle.getLineSpacing()) * i);
  }

  public static Style modCellStyleString(int paramInt1, int paramInt2, String paramString, Style paramStyle)
  {
    List localList1;
    FRFont localFRFont;
    Object localObject;
    int k;
    if (paramStyle.getVerticalText() == 1)
      localList1 = getLineTextList_Vertical(paramString, paramStyle, paramInt2);
    else
      localList1 = getLineTextList(paramString, paramStyle, paramInt1);
    if (paramStyle.getTextStyle() == 2)
    {
      localFRFont = paramStyle.getFRFont();
      int i = 0;
      int j = GraphHelper.getFontMetrics(localFRFont).getHeight() * localList1.size();
      localObject = "";
      for (k = 0; k < localList1.size(); ++k)
        if (GraphHelper.getFontMetrics(localFRFont).stringWidth((String)localList1.get(k)) > i)
        {
          localObject = (String)localList1.get(k);
          i = GraphHelper.getFontMetrics(localFRFont).stringWidth((String)localList1.get(k));
        }
      if ((i > 0) || (j > 0))
        if ((i > paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) || (j > paramInt2))
        {
          do
          {
            if (localFRFont.getSize() <= 1)
              break label894;
            localFRFont = localFRFont.applySize(localFRFont.getSize() - 1);
            i = GraphHelper.getFontMetrics(localFRFont).stringWidth((String)localObject);
            j = GraphHelper.getFontMetrics(localFRFont).getHeight() * localList1.size();
          }
          while ((i > paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) || (j > paramInt2));
          paramStyle = paramStyle.deriveFRFont(localFRFont);
        }
        else if ((i < paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) && (j < paramInt2));
    }
    else if (paramStyle.getTextStyle() == 3)
    {
      List localList2;
      int i1;
      localFRFont = paramStyle.getFRFont();
      ArrayList localArrayList = new ArrayList();
      localObject = Style.DEFAULT_STYLE;
      localObject = ((Style)localObject).deriveTextStyle(0);
      k = GraphHelper.getFontMetrics(localFRFont).getHeight();
      for (int l = 0; l < localList1.size(); ++l)
      {
        localObject = ((Style)localObject).deriveFRFont(localFRFont);
        localList2 = getLineTextList((String)localList1.get(l), (Style)localObject, paramInt1);
        for (i1 = 0; i1 < localList2.size(); ++i1)
          localArrayList.add((String)localList2.get(i1));
      }
      if (localArrayList.size() * k > paramInt2)
      {
        do
        {
          if (localFRFont.getSize() <= 1)
            break label894;
          localFRFont = localFRFont.applySize(localFRFont.getSize() - 1);
          localArrayList.clear();
          for (l = 0; l < localList1.size(); ++l)
          {
            localObject = ((Style)localObject).deriveFRFont(localFRFont);
            localList2 = getLineTextList((String)localList1.get(l), (Style)localObject, paramInt1);
            for (i1 = 0; i1 < localList2.size(); ++i1)
              localArrayList.add((String)localList2.get(i1));
          }
          k = GraphHelper.getFontMetrics(localFRFont).getHeight();
        }
        while (localArrayList.size() * k > paramInt2);
        paramStyle = paramStyle.deriveFRFont(localFRFont);
      }
      else
      {
        do
        {
          if ((localArrayList.size() * k >= paramInt2) || (localFRFont.getSize() >= 100))
            break label894;
          localFRFont = localFRFont.applySize(localFRFont.getSize() + 1);
          localArrayList.clear();
          for (l = 0; l < localList1.size(); ++l)
          {
            localObject = ((Style)localObject).deriveFRFont(localFRFont);
            localList2 = getLineTextList((String)localList1.get(l), (Style)localObject, paramInt1);
            for (i1 = 0; i1 < localList2.size(); ++i1)
              localArrayList.add((String)localList2.get(i1));
          }
          k = GraphHelper.getFontMetrics(localFRFont).getHeight();
        }
        while (localArrayList.size() * k <= paramInt2);
        localFRFont = localFRFont.applySize(localFRFont.getSize() - 1);
        paramStyle = paramStyle.deriveFRFont(localFRFont);
        localArrayList.clear();
        for (l = 0; l < localList1.size(); ++l)
        {
          localObject = ((Style)localObject).deriveFRFont(localFRFont);
          localList2 = getLineTextList((String)localList1.get(l), (Style)localObject, paramInt1);
          for (i1 = 0; i1 < localList2.size(); ++i1)
            localArrayList.add((String)localList2.get(i1));
        }
        k = GraphHelper.getFontMetrics(localFRFont).getHeight();
      }
    }
    label894: return ((Style)paramStyle);
  }

  public static Style paintCellStyleString(Graphics2D paramGraphics2D, int paramInt1, int paramInt2, String paramString, Style paramStyle)
  {
    Object localObject1;
    int k;
    int i2;
    int i7;
    int i8;
    Object localObject2;
    String str1;
    double d6;
    Paint localPaint = paramGraphics2D.getPaint();
    if (StringUtils.isBlank(paramString))
      return paramStyle;
    if (paramStyle == null)
      paramStyle = Style.DEFAULT_STYLE;
    FontRenderContext localFontRenderContext = paramGraphics2D.getFontRenderContext();
    FRFont localFRFont1 = paramStyle.getFRFont();
    Locale localLocale = FRContext.getLocale();
    if (Locale.ENGLISH.equals(localLocale))
      localFRFont1 = FRFont.getInstance("Dialog", localFRFont1.getStyle(), localFRFont1.getSize());
    if (!(ComparatorUtils.equals(localFRFont1, paramGraphics2D.getFont())))
      paramGraphics2D.setFont(localFRFont1);
    Color localColor = localFRFont1.getForeground();
    if (!(ComparatorUtils.equals(localColor, paramGraphics2D.getPaint())))
      paramGraphics2D.setPaint(localColor);
    FontMetrics localFontMetrics = paramGraphics2D.getFontMetrics();
    int i = paramStyle.getHorizontalAlignment();
    if ((paramStyle.getRotation() != 0) && (paramStyle.getVerticalText() == 0))
    {
      localObject1 = createFontAttributeMap(localFRFont1);
      AffineTransform localAffineTransform = new AffineTransform();
      localAffineTransform.rotate(-Math.toRadians(paramStyle.getRotation()));
      ((Map)localObject1).put(TextAttribute.TRANSFORM, new TransformAttribute(localAffineTransform));
      double d1 = paramInt1 / 2.0D;
      double d2 = paramInt2 / 2.0D;
      Dimension2D localDimension2D = GraphHelper.stringDimension(paramString, paramStyle.getFRFont(), -paramStyle.getRotation(), localFontRenderContext);
      if (localDimension2D.getWidth() < paramInt1)
        if (i == 2)
          d1 = localDimension2D.getWidth() / 2.0D;
        else if (i == 4)
          d1 = paramInt1 - localDimension2D.getWidth() / 2.0D - paramStyle.getPaddingLeft() * Math.cos(Math.toRadians(paramStyle.getRotation()));
      if (localDimension2D.getHeight() < paramInt2)
        if (paramStyle.getVerticalAlignment() == 1)
          d2 = localDimension2D.getHeight() / 2.0D;
        else if (paramStyle.getVerticalAlignment() == 3)
          d2 = paramInt2 - localDimension2D.getHeight() / 2.0D - paramStyle.getPaddingLeft() * Math.sin(Math.toRadians(paramStyle.getRotation()));
      label568: label1082: label2108: label1243: label2269: label867: label1904: GraphHelper.drawRotatedString(paramGraphics2D, paramString, d1, d2, -paramStyle.getRotation());
    }
    else
    {
      int i1;
      FRFont localFRFont2;
      Object localObject3;
      int i14;
      int i16;
      int i20;
      int i21;
      char c2;
      String str2;
      double d7;
      if (paramStyle.getVerticalText() == 1)
        localObject1 = getLineTextList_Vertical(paramString, paramStyle, paramInt2);
      else
        localObject1 = getLineTextList(paramString, paramStyle, paramInt1);
      if ((paramInt1 <= 0) || (((List)localObject1).size() == 0))
        return paramStyle;
      int j = localFontMetrics.getAscent();
      k = localFontMetrics.getHeight();
      int l = 0;
      int i4 = k * ((List)localObject1).size();
      int i5 = paramStyle.getSpacingBefore();
      int i6 = paramStyle.getSpacingAfter();
      i7 = paramStyle.getLineSpacing();
      i4 += i5 + i6 + i7 * ((List)localObject1).size();
      if (paramStyle.getVerticalAlignment() == 1)
        break label568:
      if (paramStyle.getVerticalAlignment() == 0)
        if (paramInt2 > i4)
          l = (paramInt2 - i4) / 2;
      else if (paramStyle.getVerticalAlignment() == 3)
        l = paramInt2 - i4;
      l += j;
      l += i5 + i7;
      if (paramStyle.getTextStyle() == 2)
      {
        localFRFont2 = localFRFont1;
        localObject2 = paramGraphics2D.getFont();
        int i9 = 0;
        int i11 = localFontMetrics.getHeight() * ((List)localObject1).size();
        localObject3 = "";
        for (i14 = 0; i14 < ((List)localObject1).size(); ++i14)
          if (localFontMetrics.stringWidth((String)((List)localObject1).get(i14)) > i9)
          {
            localObject3 = (String)((List)localObject1).get(i14);
            i9 = localFontMetrics.stringWidth((String)((List)localObject1).get(i14));
          }
        if ((i9 > 0) || (i11 > 0))
          if ((i9 > paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) || (i11 > paramInt2))
          {
            do
            {
              if (localFRFont2.getSize() <= 1)
                break label867;
              localFRFont2 = localFRFont2.applySize(localFRFont2.getSize() - 1);
              i9 = GraphHelper.getFontMetrics(localFRFont2).stringWidth((String)localObject3);
              i11 = GraphHelper.getFontMetrics(localFRFont2).getHeight() * ((List)localObject1).size();
            }
            while ((i9 > paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) || (i11 > paramInt2));
            paramStyle = paramStyle.deriveFRFont(localFRFont2);
            if (!(ComparatorUtils.equals(localFRFont2, paramGraphics2D.getFont())))
              paramGraphics2D.setFont(localFRFont2);
          }
          else if ((i9 < paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight()) && (i11 < paramInt2));
        i14 = paramGraphics2D.getFontMetrics(localFRFont2).getHeight();
        if (paramStyle.getVerticalAlignment() == 1)
          l = 0;
        else if (paramStyle.getVerticalAlignment() == 0)
          if (paramInt2 > i14 * ((List)localObject1).size())
            l = (paramInt2 - i14 * ((List)localObject1).size()) / 2;
          else
            l = 0;
        else if (paramStyle.getVerticalAlignment() == 3)
          l = paramInt2 - i14 * ((List)localObject1).size();
        l += paramGraphics2D.getFontMetrics().getAscent();
        for (i16 = 0; i16 < ((List)localObject1).size(); ++i16)
        {
          double d4 = paramStyle.getPaddingLeft();
          i20 = paramGraphics2D.getFontMetrics().stringWidth((String)((List)localObject1).get(i16));
          if (i == 2)
            break label1082:
          if (i == 0)
            d4 = (paramInt1 - i20 - paramStyle.getPaddingRight()) / 2.0D;
          else if (i == 4)
            d4 = paramInt1 - paramStyle.getPaddingRight() - i20;
          if ((i != 6) || (i == 6))
          {
            str1 = (String)((List)localObject1).get(i16);
            d6 = (paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight() - paramGraphics2D.getFontMetrics().charWidth(str1.charAt(str1.length() - 1))) / (str1.length() - 1);
            i21 = 0;
            while (true)
            {
              if (i21 >= str1.length())
                break label1243;
              c2 = str1.charAt(i21);
              str2 = new String(new StringBuffer().append(c2));
              d7 = paramStyle.getPaddingLeft() + i21 * d6;
              GraphHelper.drawString(paramGraphics2D, str2, d7, l);
              ++i21;
            }
          }
          GraphHelper.drawString(paramGraphics2D, (String)((List)localObject1).get(i16), d4, l);
          l += i14;
          i1 += i7;
        }
        paramGraphics2D.setFont((Font)localObject2);
      }
      else if (paramStyle.getTextStyle() == 3)
      {
        List localList;
        int i15;
        int i17;
        localFRFont2 = localFRFont1;
        localObject2 = paramGraphics2D.getFont();
        paramGraphics2D.setFont(localFRFont2);
        ArrayList localArrayList = new ArrayList();
        localObject3 = Style.DEFAULT_STYLE;
        localObject3 = ((Style)localObject3).deriveTextStyle(0);
        i14 = k;
        for (i16 = 0; i16 < ((List)localObject1).size(); ++i16)
        {
          localObject3 = ((Style)localObject3).deriveFRFont(localFRFont2);
          localList = getLineTextList((String)((List)localObject1).get(i16), (Style)localObject3, paramInt1);
          for (i17 = 0; i17 < localList.size(); ++i17)
            localArrayList.add((String)localList.get(i17));
        }
        if (localArrayList.size() * i14 > paramInt2)
        {
          do
          {
            if (localFRFont2.getSize() <= 1)
              break label1904;
            localFRFont2 = localFRFont2.applySize(localFRFont2.getSize() - 1);
            localArrayList.clear();
            for (i16 = 0; i16 < ((List)localObject1).size(); ++i16)
            {
              localObject3 = ((Style)localObject3).deriveFRFont(localFRFont2);
              localList = getLineTextList((String)((List)localObject1).get(i16), (Style)localObject3, paramInt1);
              for (i17 = 0; i17 < localList.size(); ++i17)
                localArrayList.add((String)localList.get(i17));
            }
            paramGraphics2D.setFont(localFRFont2);
            i15 = paramGraphics2D.getFontMetrics(localFRFont2).getHeight();
          }
          while (localArrayList.size() * i15 > paramInt2);
          paramStyle = paramStyle.deriveFRFont(localFRFont2);
        }
        else
        {
          do
          {
            if ((localArrayList.size() * i15 >= paramInt2) || (localFRFont2.getSize() >= 100))
              break label1904;
            localFRFont2 = localFRFont2.applySize(localFRFont2.getSize() + 1);
            localArrayList.clear();
            for (i16 = 0; i16 < ((List)localObject1).size(); ++i16)
            {
              localObject3 = ((Style)localObject3).deriveFRFont(localFRFont2);
              localList = getLineTextList((String)((List)localObject1).get(i16), (Style)localObject3, paramInt1);
              for (i17 = 0; i17 < localList.size(); ++i17)
                localArrayList.add((String)localList.get(i17));
            }
            paramGraphics2D.setFont(localFRFont2);
            i15 = paramGraphics2D.getFontMetrics(localFRFont2).getHeight();
          }
          while (localArrayList.size() * i15 <= paramInt2);
          localFRFont2 = localFRFont2.applySize(localFRFont2.getSize() - 1);
          paramStyle = paramStyle.deriveFRFont(localFRFont2);
          localArrayList.clear();
          for (i16 = 0; i16 < ((List)localObject1).size(); ++i16)
          {
            localObject3 = ((Style)localObject3).deriveFRFont(localFRFont2);
            localList = getLineTextList((String)((List)localObject1).get(i16), (Style)localObject3, paramInt1);
            for (i17 = 0; i17 < localList.size(); ++i17)
              localArrayList.add((String)localList.get(i17));
          }
          paramGraphics2D.setFont(localFRFont2);
          i15 = paramGraphics2D.getFontMetrics(localFRFont2).getHeight();
        }
        if (paramStyle.getVerticalAlignment() == 1)
          i1 = 0;
        else if (paramStyle.getVerticalAlignment() == 0)
          if (paramInt2 > i15 * localArrayList.size())
            i1 = (paramInt2 - i15 * localArrayList.size()) / 2;
          else
            i1 = 0;
        else if (paramStyle.getVerticalAlignment() == 3)
          i1 = paramInt2 - i15 * localArrayList.size();
        i1 += paramGraphics2D.getFontMetrics().getAscent();
        for (i16 = 0; i16 < localArrayList.size(); ++i16)
        {
          double d5 = paramStyle.getPaddingLeft();
          i20 = paramGraphics2D.getFontMetrics().stringWidth((String)localArrayList.get(i16));
          if (i == 2)
            break label2108:
          if (i == 0)
            d5 = (paramInt1 - i20 - paramStyle.getPaddingRight()) / 2.0D;
          else if (i == 4)
            d5 = paramInt1 - paramStyle.getPaddingRight() - i20;
          if ((i != 6) || (i == 6))
          {
            str1 = (String)localArrayList.get(i16);
            d6 = (paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight() - paramGraphics2D.getFontMetrics().charWidth(str1.charAt(str1.length() - 1))) / (str1.length() - 1);
            i21 = 0;
            while (true)
            {
              if (i21 >= str1.length())
                break label2269;
              c2 = str1.charAt(i21);
              str2 = new String(new StringBuffer().append(c2));
              d7 = paramStyle.getPaddingLeft() + i21 * d6;
              GraphHelper.drawString(paramGraphics2D, str2, d7, i1);
              ++i21;
            }
          }
          GraphHelper.drawString(paramGraphics2D, (String)localArrayList.get(i16), d5, i1);
          i1 += i15;
          i2 += i7;
        }
        paramGraphics2D.setFont((Font)localObject2);
      }
      else
      {
        for (i8 = 0; i8 < ((List)localObject1).size(); ++i8)
        {
          int i3;
          Object localObject4;
          int i19;
          localObject2 = (String)((List)localObject1).get(i8);
          int i10 = localFontMetrics.stringWidth((String)localObject2);
          int i12 = 0;
          if (i10 > paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight())
            i12 = 1;
          int i13 = paramStyle.getPaddingLeft();
          if (i == 2)
            break label2460:
          if (i == 0)
          {
            i13 = (paramInt1 - i10) / 2;
          }
          else if (i == 4)
          {
            i13 = paramInt1 - paramStyle.getPaddingRight() - i10;
            if ((Boolean.TRUE != FRCoreContext.TMAP.get(Thread.currentThread())) || (!(ComparatorUtils.equals(localFRFont1.getFontName(), "Tahoma"))))
              break label2460;
            i13 -= ((String)localObject2).length() / 3;
          }
          if ((i != 6) || ((((i != 6) || (paramStyle.getTextStyle() != 0))) && (((i != 6) || (paramStyle.getTextStyle() != 1) || (i12 != 0)))))
          {
            localObject4 = localObject2;
            double d3 = (paramInt1 - paramStyle.getPaddingLeft() - paramStyle.getPaddingRight() - localFontMetrics.charWidth(localObject4.charAt(localObject4.length() - 1))) / ((localObject4.length() - 1 == 0) ? 1 : localObject4.length() - 1);
            i19 = 0;
            while (true)
            {
              if (i19 >= localObject4.length())
                break label2796;
              char c1 = localObject4.charAt(i19);
              str1 = new String(new StringBuffer().append(c1));
              d6 = paramStyle.getPaddingLeft() + i19 * d3;
              if ((paramStyle.getTextStyle() == 1) && (i8 != 0))
                break label2642:
              GraphHelper.drawString(paramGraphics2D, str1, d6, i2);
              ++i19;
            }
          }
          if ((i == 6) && (paramStyle.getTextStyle() == 1) && (i12 != 0))
          {
            localObject4 = localObject2;
            StringBuffer localStringBuffer = new StringBuffer();
            int i18 = 0;
            while (true)
            {
              if (i18 >= localObject4.length())
                break label2796;
              localStringBuffer.append(localObject4.charAt(i18));
              i19 = localFontMetrics.stringWidth(new String(localStringBuffer));
              if (i19 > paramInt1)
              {
                char[] arrayOfChar = new char[128];
                localStringBuffer.getChars(0, i18 - 1, arrayOfChar, 0);
                arrayOfChar[i18] = ';
                GraphHelper.drawString(paramGraphics2D, new String(arrayOfChar), i13, i2);
                break label2796:
              }
              ++i18;
            }
          }
          GraphHelper.drawString(paramGraphics2D, (String)localObject2, i13, i2);
          i2 += k;
          i3 += i7;
        }
      }
    }
    label2460: label2642: label2796: paramGraphics2D.setPaint(localPaint);
    return ((Style)(Style)(Style)paramStyle);
  }

  public static void paintBarcode(Graphics2D paramGraphics2D, int paramInt1, int paramInt2, String paramString, Style paramStyle, BarcodeAttr paramBarcodeAttr)
  {
    BarcodeImpl localBarcodeImpl;
    try
    {
      localBarcodeImpl = BarCodeUtils.getBarcodeImpl(paramBarcodeAttr, paramString);
    }
    catch (BarcodeException localBarcodeException1)
    {
      try
      {
        localBarcodeImpl = BarCodeUtils.getBarcodeImpl(new BarcodeAttr(), null);
      }
      catch (BarcodeException localBarcodeException2)
      {
        FRContext.getLogger().log(Level.WARNING, localBarcodeException2.getMessage(), localBarcodeException2);
        return;
      }
    }
    if (paramStyle.getFRFont() != null)
    {
      localBarcodeImpl.setFont(paramStyle.getFRFont());
      localBarcodeImpl.setForeground(paramStyle.getFRFont().getForeground());
    }
    Background localBackground = paramStyle.getBackground();
    if ((localBackground != null) && (localBackground instanceof ColorBackground))
      localBarcodeImpl.setBackground(((ColorBackground)localBackground).getColor());
    int i = (paramInt1 - localBarcodeImpl.getWidth()) / 2;
    int j = (paramInt2 - localBarcodeImpl.getHeight()) / 2;
    localBarcodeImpl.draw(paramGraphics2D, i, j);
  }

  public static Map createFontAttributeMap(Font paramFont)
  {
    Map localMap = (Map)fontAttributeMapCache.get(paramFont);
    if (localMap == null)
    {
      localMap = paramFont.getAttributes();
      fontAttributeMapCache.put(paramFont, localMap);
    }
    if (paramFont instanceof FRFont)
    {
      FRFont localFRFont = (FRFont)paramFont;
      if (localFRFont.isStrikethrough())
        localMap.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    }
    return localMap;
  }
}